$(document).ready(function () {

    var nextCount = $("#nextCount").val();
    var prevCount = $("prevCount").val();

    $(".next-navigation").click(function () {
    
        var left = $('#jCarousel ul').css('margin-left').replace("px", "");
        left = left.replace("-", "");
        var right = $('#jCarousel ul').offset().right;
    
        
        var totalClick = $("#jCarousel > ul > li").length / 3;
        if (totalClick > 0)
            totalClick = parseInt(totalClick) - 1;

        
        var mod = $("#jCarousel > ul > li").length % 3
        if (mod > 0)
            totalClick = totalClick + 1;

        
        if (nextCount < totalClick) {
            
            left = parseInt(left) + 216;
            nextCount = parseInt(nextCount) + 1;
            $("#nextCount").val(nextCount);
            $("#jCarousel ul").animate({ "margin-left": "-" + left + "px" });
                //.css("margin-left", "-" + left + "px");
        }

        return false;
    }); $(".prev-navigation").click(function () {
        
        var left = $('#jCarousel ul').css('margin-left').replace("px", "");
        left = left.replace("-", "");
        
        if (nextCount > 0) {
            
            left = parseInt(left) - 216;
            nextCount = parseInt(nextCount) - 1;
            $("#nextCount").val(nextCount);
            $("#jCarousel ul").animate({ "margin-left": "-" + left + "px" });
            //.css("margin-left", "-" + left + "px");
        }

        return false;
    });
});